<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#t-overview" data-toggle="tab">总体概览</a></li>
            <li><a href="#t-process" data-toggle="tab">工序统计</a></li>
            <li><a href="#t-worker" data-toggle="tab">工人统计</a></li>
            <li><a href="#t-wage" data-toggle="tab">工资统计</a></li>
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <!-- 总体概览 -->
            <div class="tab-pane fade active in" id="t-overview">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-info">
                            <div class="panel-heading">
                                <h3 class="panel-title">生产计划概览</h3>
                            </div>
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <p><strong>计划编码：</strong>{$row.plan_code}</p>
                                        <p><strong>计划名称：</strong>{$row.plan_name}</p>
                                        <p><strong>产品名称：</strong>{$row.product_name}</p>
                                        <p><strong>产品型号：</strong>{$row.product_model}</p>
                                    </div>
                                    <div class="col-md-6">
                                        <p><strong>计划数量：</strong><span class="text-primary">{$row.total_quantity}</span></p>
                                        <p><strong>已分配数量：</strong><span class="text-success">{$stats.total_allocated}</span></p>
                                        <p><strong>已报工数量：</strong><span class="text-warning">{$stats.total_reported}</span></p>
                                        <p><strong>总工时：</strong><span class="text-info">{$stats.total_hours} 小时</span></p>
                                    </div>
                                </div>
                                
                                <!-- 进度条 -->
                                <div class="row" style="margin-top: 20px;">
                                    <div class="col-md-12">
                                        <h4>生产进度</h4>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" role="progressbar" 
                                                 style="width: {($stats.total_reported / $row.total_quantity * 100)|round}%">
                                                {($stats.total_reported / $row.total_quantity * 100)|round}%
                                            </div>
                                        </div>
                                        <p class="text-muted">已完成：{$stats.total_reported} / {$row.total_quantity}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 工序统计 -->
            <div class="tab-pane fade" id="t-process">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-success">
                            <div class="panel-heading">
                                <h3 class="panel-title">工序完成情况</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>工序名称</th>
                                            <th>分配数量</th>
                                            <th>已报工数量</th>
                                            <th>完成率</th>
                                            <th>实际工时</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {foreach $stats.process_stats as $processName => $processStat}
                                        <tr>
                                            <td>{$processName}</td>
                                            <td>{$processStat.allocated}</td>
                                            <td>{$processStat.reported}</td>
                                            <td>
                                                {if $processStat.allocated > 0}
                                                    {$processStat.completion_rate}%
                                                {else}
                                                    0%
                                                {/if}
                                            </td>
                                            <td>{$processStat.hours} 小时</td>
                                        </tr>
                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 工人统计 -->
            <div class="tab-pane fade" id="t-worker">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-warning">
                            <div class="panel-heading">
                                <h3 class="panel-title">工人工作统计</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>工人姓名</th>
                                            <th>分配数量</th>
                                            <th>已报工数量</th>
                                            <th>完成率</th>
                                            <th>实际工时</th>
                                            <th>工作效率</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {foreach $stats.worker_stats as $workerName => $workerStat}
                                        <tr>
                                            <td>{$workerName}</td>
                                            <td>{$workerStat.allocated}</td>
                                            <td>{$workerStat.reported}</td>
                                            <td>
                                                {if $workerStat.allocated > 0}
                                                    {$workerStat.completion_rate}%
                                                {else}
                                                    0%
                                                {/if}
                                            </td>
                                            <td>{$workerStat.hours} 小时</td>
                                            <td>
                                                {if $workerStat.hours > 0}
                                                    {$workerStat.efficiency} 件/小时
                                                {else}
                                                    0 件/小时
                                                {/if}
                                            </td>
                                        </tr>
                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 工资统计 -->
            <div class="tab-pane fade" id="t-wage">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-danger">
                            <div class="panel-heading">
                                <h3 class="panel-title">工资统计</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>工人姓名</th>
                                            <th>已报工数量</th>
                                            <th>实际工时</th>
                                            <th>计件工资</th>
                                            <th>工时工资</th>
                                            <th>总工资</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {foreach $stats.worker_stats as $workerName => $workerStat}
                                        <tr>
                                            <td>{$workerName}</td>
                                            <td>{$workerStat.reported}</td>
                                            <td>{$workerStat.hours} 小时</td>
                                            <td>¥{$workerStat.wage}</td>
                                            <td>¥{$workerStat.hourly_wage}</td>
                                            <td class="text-success"><strong>¥{$workerStat.total_wage}</strong></td>
                                        </tr>
                                        {/foreach}
                                    </tbody>
                                    <tfoot>
                                        <tr class="info">
                                            <td><strong>总计</strong></td>
                                            <td><strong>{$stats.total_reported}</strong></td>
                                            <td><strong>{$stats.total_hours} 小时</strong></td>
                                            <td><strong>¥{$stats.total_piece_wage}</strong></td>
                                            <td><strong>¥{$stats.total_hourly_wage}</strong></td>
                                            <td class="text-success"><strong>¥{$stats.total_wage}</strong></td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
